<!-- 1 入库,2 出库,3 需求，4、成品入库 5、合成成品 6、仓库发仓库 -->
<template>
	<view class="page">   
		<c-header bgColor="bg-white">
			<view class="header" slot="header">
				<navigator open-type="navigateBack" :delta="1" hover-class="none" class="t-btn back-btn iconfont f-s46">&#xe63b;</navigator>
				<view class="title">{{title}}</view> 
			</view>
		</c-header> 
		<view  class="body">  
			<template v-if="isshow">
				<view class="status-icon">
					<template > 
						<image v-if="detail.apply_status==1" src="@/static/images/status_icon/apply_status11.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==2" src="@/static/images/status_icon/apply_status2.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==3" src="@/static/images/status_icon/apply_status13.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==9" src="@/static/images/status_icon/apply_status27.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==10" src="@/static/images/status_icon/apply_status26.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==4 && (detail.apply_type==5 || detail.apply_type==4 || detail.apply_type==1)" src="@/static/images/status_icon/apply_status14.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==6 && (detail.apply_type==6)" src="@/static/images/status_icon/apply_status14.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==4 && (detail.apply_type==2 || detail.apply_type==6)" src="@/static/images/status_icon/apply_status4.png" mode="widthFix"></image>
						<image v-if="detail.apply_status==-1" src="@/static/images/status_icon/apply_status-1.png" mode="widthFix"></image>						
					</template>		 
				</view> 
				
				<template> 
					<view class="goods-wrap m-b2">
						<view class="item">
							<text class="label">申请人</text>
							<text>{{detail.username||detail.apply_name}}</text> 
						</view>
						<view class="item">
							<text class="label">申请时间</text>
							<text>{{detail.create_time}}</text> 
						</view>
						<view v-if="detail.apply_type == 4 || detail.apply_type == 5" class="item">
							<text class="label">入库状态</text>
							<text v-if="detail.apply_type == 5">合成产品（材料合成）</text> 
							<text v-if="detail.apply_type == 4">成品入库（采购产品）</text>
						</view> 
					</view>
					<view class="goods-wrap m-b2" v-for="(item,index) in detail.product_list" :key="index"> 	
						<view class="hd-title"> 
							<text v-if="detail.apply_type == 1 || detail.apply_type == 4 || detail.apply_type == 5">入库清单{{index+1}}</text>
							<text v-if="detail.apply_type == 2">出库清单{{index+1}}</text>
							<text v-if="detail.apply_type == 3">需求清单{{index+1}}</text>
							<text v-if="detail.apply_type == 6">仓库发仓库清单{{index+1}}</text> 
						</view>	 
						<view class="item">
							<text class="label">货物名称</text>
							<text>{{item.pname}}<text v-if="Number(item.one_price)==0">（赠送）</text></text> 
						</view>
						<!-- <view class="item" v-for="(subitem,subindex) in item.hp_count" :key="subindex">
							<text class="label">{{subitem.sname}}</text>
							<text v-if="item.count">{{subitem.pre_count+' '+item.uname}}</text>
							<text v-else>{{subitem.p_count+' '+item.uname}}</text> 
						</view> -->
						
						<template>
							<template v-if="item.sname">
								<template v-if="detail.apply_type != 6">
									<view class="item">
										<text v-if="detail.apply_type == 1 || detail.apply_type == 4 || detail.apply_type == 5" class="label">入库仓库</text>
										<text v-if="detail.apply_type == 2" class="label">发货仓库</text>
										<text v-if="detail.sname">{{detail.sname.sname}}</text> 
									</view>  
								</template>
								
								<template v-else>
									<view class="item">
										<text class="label">入库仓库</text>
										<text v-if="detail.sname">{{detail.sname.sname}}</text> 
									</view>
									<view class="item">
										<text class="label">发货仓库</text>
										<text v-if="detail.send_sname">{{detail.send_sname.sname}}</text> 
									</view> 
								</template> 
							</template>
							
							<view class="item">
								<text class="label">申请数量</text>
								<text>{{Number(item.p_count)}}{{item.uname}} <text v-if="item.count">({{item.count}})</text></text> 
							</view>  
							<view class="item m-b2">
							 	<text class="label">单价</text>
							 	<text>{{Number(item.one_price)}}元</text> 
							 </view>
						</template>
						
						<template v-if="detail.apply_type == 2">
							<!-- <u-button type="primary" text="新增出库信息" size="small" class="m-b2"></u-button> -->
							<view class="store-list-table">
								<u-row v-if="detail.apply_status==2||(detail.apply_status==1&&userInfo.id==detail.sp_user)" justify="space-between" class="th m-b1">
									<u-col span="3">
										<view class="t-c f-wb f-s28">出货仓库</view>
									</u-col>
									<u-col span="3">
										<view class="t-c f-wb f-s28">仓库管理员</view>
									</u-col>
									<u-col span="3">
										<view class="t-c f-wb f-s28">{{detail.apply_status==2?'出货数量':'库存'}}</view>
									</u-col>
									<u-col span="3">
										<view class="t-c f-wb f-s28">{{detail.apply_status==2?'状态':'出库数量'}}</view>
									</u-col>
								</u-row>
								<template v-if="detail.apply_status==2">
									<u-row justify="space-between" class="td m-b1" v-for="(i,k) in item.inout_branch" :key="k">
										<u-col span="3">
											<view class="t-c f-s28">{{i.store_name}}</view>
										</u-col>
										<u-col span="3">
											<view class="t-c f-s28">{{i.store_username}}</view>
										</u-col>
										<u-col span="3">
											<view class="t-c f-s28">{{i.num}}{{item.uname}}</view>
										</u-col>
										<u-col span="3">
											<view class="t-c f-s28">{{i.ship_status==0?'未发货':'已发货'}}</view>
										</u-col>
									</u-row>
								</template>
								<template v-if="detail.apply_status==1&&userInfo.id==detail.sp_user">
									<u-row justify="space-between" class="td m-b1" v-for="(i,k) in item.hp_count" :key="k"  >
										<u-col span="3">
											<view class="t-c f-s28">{{i.sname}}</view>
										</u-col>
										<u-col span="3">
											<view class="t-c f-s28">{{i.store_username}}</view>
										</u-col>
										<u-col span="3">
											<view class="t-c f-s28">{{Number(i.pre_count)}}{{item.uname}}</view>
										</u-col>
										<u-col span="3">
											<view class="t-c f-s28"><u-input type="digit" v-model="i.num" :disabled="Number(i.pre_count)>0?false:true" placeholder="出库数量" style="height:30rpx;text-align: center;"></u-input></view>
										</u-col>
									</u-row>
								</template>								
							</view>
						</template>
						 				 
					</view>	
							
					<view v-if="detail.partslist.length>0" class="goods-wrap m-b2" v-for="(item,index) in detail.partslist" :key="index">
						<view class="hd-title"> 
							<text>材料清单{{index+1}}</text> 
						</view>	 
						<view class="item">
							<text class="label">材料名称</text>
							<text>{{item.pname}}</text> 
						</view>
						<view class="item">
							<text class="label">库存数量</text>
							<text>{{item.z_count}}{{item.uname}}</text> 
						</view>
						<view class="item">
							<text class="label">入库数量</text>
							<text>{{item.p_count}}{{item.uname}}</text> 
						</view>
						<view class="item">
							<text class="label">单价</text>
							<text>{{item.price}}元</text> 
						</view>
						<view class="item">
							<text class="label">总价</text>
							<text>{{(Number(item.p_count)+Number(item.z_count))*item.price}}元</text> 
						</view> 
						 			 
					</view>
					
					<view v-if="detail.apply_type == 2" class="goods-wrap m-b2">
						<view class="item">
							<text class="label">项目名称</text>
							<text>{{detail.projectname}}</text> 
						</view>
						<view v-if="detail.apply_user==userInfo.id" class="item">
							<text class="label">货款(元)</text>
							<text>{{detail.product_money}}</text> 
						</view> 						
						<view class="item">
							<text class="label">快递方式</text>
							<text v-if="detail.sendproduct[0].send_type == 1">物流-自提</text> 
							<text v-if="detail.sendproduct[0].send_type == 2">物流-送货上门</text>
							<text v-if="detail.sendproduct[0].send_type == 3">快递</text>
						</view>  
						<view class="item">
							<text class="label">支付方式</text>
							<text v-if="detail.sendproduct[0].pay_type == 1">寄付</text> 
							<text v-if="detail.sendproduct[0].pay_type == 2">到付</text>
							<text v-if="detail.sendproduct[0].pay_type == 3">部分付</text>
							<text v-if="detail.sendproduct[0].pay_type == 4">月结</text>
						</view>
						<view class="item">
							<text class="label">结款状态</text>
							<text v-if="detail.project_status == 1">未结清</text> 
							<text v-if="detail.project_status == 2">未结清</text>
							<text v-if="detail.project_status == 3">部分结清</text> 
						</view>
						<view v-if="detail.apply_user==userInfo.id" class="item">
							<text class="label">已结款(元)</text>
							<text>{{detail.payments}}</text>  
						</view>
						<view v-if="detail.sendproduct[0].NAME" class="item" @click="copy(detail.sendproduct[0].NAME)">
							<text class="label">客户姓名</text>
							<text>{{detail.sendproduct[0].NAME}}</text> 				 
						</view>
						<view v-if="detail.apply_user == userInfo.id || detail.last_receive_user == userInfo.id" class="item">
							<text class="label">手机号</text>
							<view class="phone">
								<text>{{detail.sendproduct[0].phone}}</text>
								<view class="link">
									<view class="f-blue m-r2" @click="copy(detail.sendproduct[0].phone)">复制</view>
									<view class="f-blue" @click="call(detail.sendproduct[0].phone)">拨打</view>
								</view>
							</view>
							  
						</view>
						<view v-if="detail.sendproduct[0].address" class="item">
							<text class="label" style="flex-shrink: 0;">详细地址</text>
							<view class="phone" style="width: 70%;">
								<text style="width: 80%;">{{detail.sendproduct[0].address}}</text>  
								<view class="link">
									<view class="f-blue m-r2" @click="copy(detail.sendproduct[0].address)">复制</view> 
								</view>
							</view>
						</view>				
					</view>
					
					<view v-if="detail.sendproduct && detail.sendproduct.length>0 && detail.sendproduct[0].send_name && detail.apply_status==4 && (detail.apply_user == userInfo.id || detail.last_receive_user==userInfo.id)" class="goods-wrap m-b2">
						<view class="item">
							<text class="label">物流名字</text>
							<text>{{detail.sendproduct[0].send_name}}</text>  
						</view>
						<view class="item">
							<text class="label">物流单号</text>
							<text>{{detail.sendproduct[0].send_num}}</text>  
						</view>
						<view class="item">
							<text class="label">物流费用</text>
							<text>{{detail.sendproduct[0].pay_money}}元</text>  
						</view> 							 
					</view> 
					
					<view v-if="hetong.length>0" class="goods-wrap m-b2">
						<view class="hd-title">
							<text>合同</text>						 
						</view>	
						<view class="m-b2">
							<c-uploadFile-hetong :currentfiles="hetong" module="hetong"></c-uploadFile-hetong>				 
						</view>	
					</view>
									
					<view v-if="detail.files_path.length>0" class="goods-wrap m-b2">
						<view class="hd-title">
							<text>凭证/申请</text>						 
						</view>	
						<view class="m-b2">
							<view class="detail-wrap">
								<view class="detail-pic-item">
									<view class="detail-pic">
										<view v-if="(item.file_type==1||item.file_type==2||item.file_type==4||item.file_type==6)&&(item.file_ext=='jpg'||item.file_ext=='png'||item.file_ext=='jpeg')" class="pic-item" v-for="(item,index) in detail.files_path" :key="index">
											<image src="@/static/images/filter_bg.png" mode="widthFix">
												<!-- 占位 -->
											</image>
											<view class="img-wrap" @click="preview(index)">
												<image class="img" :src="item.files_path" mode="widthFix"></image>
											</view>
										</view>
									</view>
									
								</view>
							</view> 
						</view>	 
					</view>
					
					<view v-if="detail.files_path.length>0" class="goods-wrap m-b2">	
						<view class="hd-title">
							<text>凭证/发货</text>						 
						</view>	
						<view class="m-b2">
							<view class="detail-wrap">
								<view class="detail-pic-item">
									<view class="detail-pic">
										<view v-if="item.file_type==3&&(item.file_ext=='jpg'||item.file_ext=='png'||item.file_ext=='jpeg')" class="pic-item" v-for="(item,index) in detail.files_path" :key="index">
											<image src="@/static/images/filter_bg.png" mode="widthFix">
												<!-- 占位 -->
											</image>
											<view class="img-wrap" @click="preview(index)">
												<image class="img" :src="item.files_path" mode="widthFix"></image>
											</view>
										</view>
									</view>
									
								</view>
							</view> 
						</view>	
					</view>
					
					<view v-if="detail.files_path.length>0" class="goods-wrap m-b2">	
						<view class="hd-title">
							<text>凭证/签收</text>						 
						</view>	
						<view class="m-b2">
							<view class="detail-wrap">
								<view class="detail-pic-item">
									<view class="detail-pic">
										<view v-if="(item.file_type==7||item.file_type==8||item.file_type==9)&&(item.file_ext=='jpg'||item.file_ext=='png'||item.file_ext=='jpeg')" class="pic-item" v-for="(item,index) in detail.files_path" :key="index">
											<image src="@/static/images/filter_bg.png" mode="widthFix">
												<!-- 占位 -->
											</image>
											<view class="img-wrap" @click="preview(index)">
												<image class="img" :src="item.files_path" mode="widthFix"></image>
											</view>
										</view>
									</view>
									
								</view>
							</view> 
						</view>	 
					</view>
					 
					
					<view class="goods-wrap m-b2"> 
						<view class="item">
							<text class="label">申请人备注</text>
							<!-- <text>{{detail.apply_reason}}</text> -->
						</view>	
						<view class="item" v-html="detail.htmlNode"> 
						</view>
					</view>
					<view class="goods-wrap m-b2">
						<view class="item">
							<text class="label">签收方式</text>
							<text v-if="detail.sign_type==1">个人</text>  
							<text v-if="detail.sign_type==2">公司(无章)</text>  
							<text v-if="detail.sign_type==3">公司(有章)</text>  
						</view> 	
						<view v-if="sign_str" class="item">
							<text class="label" style="flex-shrink: 0;">签收链接</text>
							<view class="phone" style="width: 70%;">
								<text style="width: 80%;" class="split">{{sign_str}}</text>  
								<view class="link">
									<view class="f-blue m-r2" @click="copy(sign_str)">复制</view> 
								</view>
							</view>
						</view>										 
					</view>
				</template>
			</template>
		</view> 
		
		<view v-if="userInfo.id==detail.sp_user&&refusels.length>0" class="refusels">
			<view class="item m-b2" v-for="(item,index) in refusels" :key="index">
				<view class="text">{{item.tips}}</view>
				<view class="btn-wrap">
					<u-button type="primary" text="同意" size="small" class="m-r2" @click="currentrefuselsindex=index;refuseapproval('1');"></u-button>
					<u-button type="warning" text="驳回" size="small" @click="showRemark=true;currentrefuselsindex=index"></u-button>
				</view>
			</view>
		</view>
		
		<c-footer v-if="detail.apply_type==1">
			<view slot="content" class="btn-wrap">
				<view class="add-btn" @click="copyNo">复制订单</view>
				<view v-if="(detail.apply_status==6 && detail.apply_type==2) || (detail.apply_status==4 && (detail.apply_type==2 || detail.apply_type==6))" class="add-btn" @click="showSign=true;">生成链接</view>
			</view>			
		</c-footer>
		
		<!-- 仓库互发 -->
		<c-footer v-if="detail.apply_type==6&&detail.apply_status==1&&userInfo.id==detail.sp_user">
			<view slot="content" class="btn-wrap">
				<template>
					<view class="add-btn" @click="agree">同意</view>
					<view class="add-btn" @click="disAgree">不同意</view>
				</template>				 
			</view>			
		</c-footer>
		
		<c-footer v-if="detail.apply_type==2&&detail.apply_status==1 &&userInfo.id==detail.sp_user">
			<view slot="content" class="btn-wrap">
				<template v-if="detail.apply_status!=2">
					<view class="add-btn" @click="agreeSend">同意</view>
					<view class="add-btn" @click="disAgree">不同意</view>
				</template>
				<view class="add-btn" @click="copyNo">复制订单</view>
				<view v-if="(detail.apply_status==6 && detail.apply_type==2) || (detail.apply_status==4 && (detail.apply_type==2 || detail.apply_type==6))" class="add-btn" @click="showSign=true;">生成链接</view>
			</view>			
		</c-footer>
		
		<!-- 入库 -->
		<c-footer v-if="detail.apply_type==4&&detail.apply_status==1&&userInfo.id==detail.sp_user">
			<view slot="content" class="btn-wrap">
				<template>
					<view class="add-btn" @click="isChoseStorehouse=true">同意</view>
					<view class="add-btn" @click="disAgree">不同意</view>
				</template>				 
			</view>			
		</c-footer>
		
		<c-footer v-if="(detail.apply_status==6 && detail.apply_type==2) || (detail.apply_status==4 && (detail.apply_type==2 || detail.apply_type==6))">
			<view slot="content" class="btn-wrap"> 
				<view class="add-btn" @click="copyNo">复制订单</view>
				<view class="add-btn" @click="showSign=true;">生成链接</view>
			</view>			
		</c-footer> 
		
		<template v-if="detail.apply_user == userInfo.id || detail.sp_user == userInfo.id || detail.last_receive_user == userInfo.id">
			<view v-if="detail.apply_status != '-1' || detail.apply_status != 3 || detail.apply_status != 5" class="fixed-btn bz" @click="show=true" >
				<image src="../../static/images/time_icon.png" mode="widthFix"></image>
				<text>更新备注</text>
			</view>
		</template>
		
		<!-- <view v-if="detail.project_status&&detail.project_status==1" class="fixed-btn jq" ><text>需要结清</text></view> -->
		
		<u-popup :show="show" mode="center" @close="close" @open="open" :closeable="true">
			<view class="update-apply-reason">
				<u--text text="更新备注" size="30" bold align="center" class="m-b2"></u--text>
				<u--form ref="uForm" class="form-wrap m-b2">
					<u--textarea v-model="apply_reason" placeholder="请输入新备注" :maxlength="300" count  ></u--textarea>
				</u--form>
				<u-upload
					width="120"
					height="120"
					:fileList="apply_reason_files"
					@afterRead="afterRead($event)"
					@delete="deletePic"
					:previewFullImage="true"
					name="1"
					multiple
					:maxCount="10"
				></u-upload>
				<u-button type="primary" text="确定" size="small" @click="updateapplyreason"></u-button>
			</view>
		</u-popup>
		
		<u-popup :show="showRemark" mode="center" @close="showRemark=false" :closeable="true">
			<view class="update-apply-reason" style="width: 450rpx;">
				<u--text text="驳回原因" size="30" bold align="center" class="m-b2"></u--text>
				<u--form ref="uForm" class="form-wrap m-b2">
					<u--input v-model="remark" placeholder="请输入驳回原因" :maxlength="300" count ></u--input>
				</u--form>
				<u-button type="primary" text="确定" size="small" @click="refuseapproval('2')"></u-button>
			</view>
		</u-popup>
		
		<u-popup :show="isChoseStorehouse" :round="5" mode="center" closeable @close="isChoseStorehouse=false"> 
			<view class="storehouse-pupup"> 
			    <u--form labelPosition="left" ref="uForm" class="m-b2">
			    	<u-form-item labelWidth="120" label="审批人"	prop="userInfo.sex"	borderBottom ref="item1" @click="storehouse.isShow=true;">
			    		<u--input v-model="params.next_user_name" disabled disabledColor="#ffffff" placeholder="请选择下一位审批人" border="none" style="pointer-events: none;"></u--input>
			    		<u-icon	slot="right" name="arrow-right"></u-icon>
			    	</u-form-item>		 
				</u--form>
				<u-button type="primary" text="确定" size="small" @click="agreeSend"></u-button>
			</view>
		</u-popup>
		
		<u-popup :show="showSign" mode="center" @close="close" @open="open" :closeable="true">
			<view class="update-apply-reason">
				<u--text text="签收方式" size="30" bold align="center" class="m-b2"></u--text>
				<u-radio-group
				    v-model="sign_type"
				    placement="column" 
					size="32"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px',fontSize:'16px'}"
				      v-for="(item, index) in signTypes"
				      :key="index"
				      :label="item.name"
				      :name="item.id"
						labelSize="28"
				    >
				    </u-radio>
				  </u-radio-group>
				<u-button type="primary" text="确定" size="small" @click="creatLink"></u-button>
			</view>
		</u-popup>
		
		<u-picker :show="storehouse.isShow" :columns="storehouse.data" keyName="next_realname" itemHeight="90" :closeOnClickOverlay="true" @cancel="storehouse.isShow=false" @confirm="changestorehouse" @close="storehouse.isShow=false"></u-picker>
	</view>
</template>

<script>  
	import {
		previewImage,htmlParse
	} from '@/common/util.js'
	import {uploadToServe} from '@/common/util.js'
	import {
		IMG_PATH
	} from '../../config.js'
	export default {
		data() {
			return {
				title:'',
				isLogin:false, 
				show:false,
				isshow:false,
				isIphoneX:getApp().globalData.isIphoneX,
				userInfo:uni.getStorageSync('userInfo'),
				type:'',
				id:'',
				apply_id:'',
				order_id:'',
				detail:{},
				total:0, 
				pics:[],
				loadingState:{
					default:false,
					loading:false,
					completed:false
				},
				apply_reason:'',
				apply_reason_files:[],
				params:{
					page:1,
					limit:15,
					search:'', 
					next_user:'',
					next_user_name:''
				},
				signTypes:[
					{
						id:'1',
						name:'个人'
					},
					{
						id:'2',
						name:'公司(无章)'
					},
					{
						id:'3',
						name:'公司(盖章)'
					}
				], 
				sign_type:'1',
				sign_str:'',
				showSign:false,
				branch_data:[],
				refusels:[],
				currentrefuselsindex:'',
				remark:'',
				showRemark:false,
				storehouse:{
					isShow:false,
					data:[],
					defaultIndex:[]
				},
				isChoseStorehouse:false,
				hetong:[]
			}
		},
		async onLoad(params) {   
			this.type=params.type; 
			
			if(params.notice_id){
				this.id=params.notice_id;
				this.title='申请ID'+this.id; 
			}
			if(params.apply_id){
				this.apply_id=params.apply_id;
				this.getmedetails();
				this.title='申请ID'+this.apply_id; 
			}			
			if(params.order_id){
				this.order_id=params.order_id;
				this.orderpartsdetails();
				this.title='申请ID'+this.order_id; 
			}	
			this.getrefusels();				
		},
		onShow() {
			
		},
		onReachBottom(){
			 
		},
		methods: { 
			// 删除图片
			deletePic(event) {
				this.apply_reason_files.splice(event.index, 1) 
			},
			
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file);
				let api_url='/api/product/uploadfile';
				let fileListLen = 0; 
				
				fileListLen = this.apply_reason_files.length;
				lists.map((item) => {
					this.apply_reason_files.push({
						...item,
						status: 'uploading',
						message: '上传中'
					}) 
				})			 				
				
				for (let i = 0; i < lists.length; i++) { 
					uploadToServe({
						url: api_url,
						filePath: lists[i].url,
						name: 'fileinput',
						formData: { 
							apply_type:11   // 1入库,2出库,3发货,4（货款）结清  10 合同  11 备注
						}
					}).then((res)=>{ 
						let item = this.apply_reason_files[fileListLen];
						this.apply_reason_files.splice(fileListLen, 1, Object.assign(item, {
							status: 'success',
							message: '',
							url: `${IMG_PATH}${res.data.file_path}/${res.data.file_name}`,
							name:res.data.file_name
						}))					
						fileListLen++ 
					}) 
				}
			}, 
			
			
			async mestorehouse(){
				let res=await this.$api.user_api.mestorehouse({
					apply_id:this.apply_id,
					apply_node:this.detail.apply_node,
				}) 
				if(res.data.code==200){
					this.$set(this.storehouse.data,0,res.data.data); 
				}
			},
			
			changestorehouse(e){ 
				console.log(e)
				this.params.next_user=e.value[0].next_user;
				this.params.next_user_name=e.value[0].next_realname;
				this.storehouse.isShow=false;
			},
			
			async refuseapproval(status){
				let item=this.refusels[this.currentrefuselsindex];
				let res={};
				let _this=this;
				if(status==1){
					uni.showModal({
						content:'确定同意'+item.tips+'吗？',	
						async success(m_res) {
							if(m_res.confirm){
								res=await _this.$api.user_api.refuseapproval({
									apply_id:_this.apply_id,
									storehouseman:item.storehouseman,
									is_agree:status,
									remark:'同意'
								})   
								if(res.data.code==200){
									if(_this.refusels.length==1){
										this.$showToast({
											title:res.data.msg 
										}) 
										uni.navigateBack({
											delta:1
										})
									}else{
										this.getrefusels();
									}
									
								}
							}
						}
					})
				}
				
				if(status==2){
					if(this.remark==''){
						this.$showToast({
							title:'请输入驳回原因'
						})
						return
					}
					res=await _this.$api.user_api.refuseapproval({
						apply_id:_this.apply_id,
						storehouseman:item.storehouseman,
						is_agree:status,
						remark:_this.remark
					})  
					if(res.data.code==200){
						if(this.refusels.length==1){
							this.$showToast({
								title:res.data.msg 
							})
							this.$store.commit('KUCUN_SHENPI_UPDATE',1);
							uni.navigateBack({
								delta:1
							})
						}else{
							this.getrefusels();
						}
						
					}
				}
				
				
			},
			async getrefusels(){
				let res=await this.$api.user_api.refusels({
					apply_id:this.apply_id
				}) 
				if(res.data.code==200){
					this.refusels=res.data.data;
				}
			},
			async agree(){
				let res=await this.$api.user_api.meagree({
					apply_id:this.apply_id,
					apply_node:this.detail.apply_node, 
				})  
				if(res.data.code==200){
					this.$showToast({
						title:res.data.msg 
					})
					this.$store.commit('KUCUN_SHENPI_UPDATE',1);
					uni.navigateBack({
						delta:1
					})
				}
			},
			async agreeSend(){	
				let branch_data=[];
				if(this.detail.apply_type==2){
					for(let i in this.detail.product_list){
						this.detail.product_list[i].hp_count_num=0;
						if(this.detail.product_list[i].hp_count.length>0){
							this.detail.product_list[i].hp_count.forEach(j=>{
								this.detail.product_list[i].hp_count_num+=Number(j.num); 
								if(j.num>0){
									let item={};								
									item.p_id=this.detail.product_list[i].p_id;
									item.num=j.num;
									item.storehouseid=j.storehouse;
									item.store_name=j.sname;
									item.storehouseman=j.storehouseman;
									branch_data.push(item);
								}
								
							})
						}
						if(this.detail.product_list[i].hp_count_num!=this.detail.product_list[i].p_count){
							this.$showToast({
								title:this.detail.product_list[i].pname+'出库总数量和申请数量不一致'
							})
							return
						}
					} 
				}
				
				
				let res=await this.$api.user_api.menextuserwx({
					apply_id:this.apply_id,
					apply_node:this.detail.apply_node,
					next_user:this.params.next_user,
					uuid:this.detail.apply_user,
					apply_type:this.detail.apply_type,
					decript:'同意',
					branch_data:JSON.stringify(branch_data)
				})  
				if(res.data.code==200){
					this.$showToast({
						title:res.data.msg 
					})
					this.$store.commit('KUCUN_SHENPI_UPDATE',1);
					uni.navigateBack({
						delta:1
					})
				}
			},
			async disAgree(){
				let res=await this.$api.user_api.medisagree({
					apply_id:this.apply_id,
					apply_node:this.detail.apply_node,
				})
				if(res.data.code==200){
					this.$showToast({
						title:res.data.msg 
					})
					this.$store.commit('KUCUN_SHENPI_UPDATE',1);
					uni.navigateBack({
						delta:1
					})
				}
			},
			copyNo(){   
				if(this.detail.apply_type==1){ 
					
				}else if(this.detail.apply_type==2){
					uni.navigateTo({
						url:'/package_kucun/chuku/chuku?apply_id='+this.apply_id
					})
				}else if(this.detail.apply_type==6){
					uni.navigateTo({
						url:'/package_kucun/cangku-huhuan/cangku-huhuan?apply_id='+this.apply_id
					})
				}   
			},
			async creatLink(){ 
				let res=await this.$api.user_api.mesignurl({
					apply_id:this.apply_id,
					sign_type:this.sign_type
				})  
				if(res.data.code==200){
					this.sign_str=res.data.data; 
					this.$showToast({
						title:'生成成功' 
					})
					this.close();
				}else{
					this.$showToast({
						title:'生成失败' 
					})
					this.close();
				}
			},
			open() {
				this.show = true;
			},
			close() {
				this.show = false;
				this.showSign=false;
				
			} ,
			copy(data){
				uni.setClipboardData({
					data:data
				})
			},
			call(phone){
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
			},
			async updateapplyreason(){ 
				if(this.apply_reason==''){
					this.$showToast({
						title:'请输入新备注' 
					})
					return
				}
				let res=await this.$api.user_api.meapplyreason({
					apply_id:this.apply_id,
					decript:this.apply_reason
				}) 
				if(res.data.code==200){
					this.getmedetails();
					this.close();
				}
			},
			async getmedetails(){ 
				let res=await this.$api.user_api.medetails({
					notice_id:this.id,
					apply_id:this.apply_id
				});    
				console.log(res)
				if(res.data.code==200){  
					this.isshow=true;
					this.sign_str=res.data.data.m.sign_str;		 
					if(res.data.data.m.files_path.length>0){
						res.data.data.m.files_path.forEach(item=>{
							item.file_name=item.files_path;
							item.files_path=IMG_PATH+item.file_path+'/'+item.files_path; 							
							if(item.file_type==10){
								this.hetong.push(item)
							}
						})
					}
					res.data.data.m.product_list.forEach(i=>{						
						if(i.hp_count.length>0){
							i.hp_count.forEach(j=>{
								j.num='';
								j.pre_count=j.p_count;
								if(i.count){
									j.pre_count=Math.floor(Number(j.p_count)/(i.pre_num/i.p_count));
								}
							})
						} 
					})
					res.data.data.m.htmlNode=[]; 
					res.data.data.m.htmlNode=htmlParse(res.data.data.m.apply_reason) 
					console.log(typeof(res.data.data.m.htmlNode))
					this.detail=res.data.data.m; 
					this.mestorehouse();
				}
			}, 
			
			async orderpartsdetails(){
				let res=await this.$api.user_api.orderpartsdetails({
					order_id:this.order_id 
				});     
				if(res.data.code==200){  
					this.isshow=true;
					if(res.data.data.files_path.length>0){
						res.data.data.files_path.forEach(item=>{
							item.files_path=IMG_PATH+item.file_path+'/'+item.file_name; 
						})
					}
					 
					this.detail=res.data.data 
					
				}
			}, 
			
			
			// 图片预览
			preview: function(idx) {
				let img_list = [];
				this.detail.files_path.forEach(item => {
					img_list.push(item.files_path)
				})
				previewImage({
					data: img_list,
					index: idx
				})
			}, 
			
		},
		computed:{
			 
		},
		watch:{
			 
		}
	}
</script>

<style lang="less">
	.add-btn{
		height: 36px;
		line-height: 36px;
		width: 96%;
		margin: 5px auto;
		background: #1cab1b;
		border-radius: 8rpx;
		color: #fff;
		font-size: 30rpx;
		text-align: center;
	}  
	.storehouse-pupup{
		padding: 50rpx 20rpx 20rpx;
	}
	.refusels{
		padding: 30rpx;
		.item{
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 30rpx;
		}
		.btn-wrap{
			display: flex;
			align-items: center;
		}
	}
	.store-list-table{
		.th{
			height: 60rpx;
			line-height: 60rpx;
			background: #f5f5f5;
		}
		.td{
			height: 60rpx;
			line-height: 60rpx;
		}
	}
	.btn-wrap{
		.add-btn{
			margin: 0 10rpx;
		}
	}
	.status-icon{
		position: absolute;
		top: 160rpx;
		right: 0;
		image{
			width: 350rpx;
		}
	}
	.update-apply-reason{
		padding:30rpx;
		width: 450rpx;
	}
	.goods-wrap{
		padding: 0 20rpx;
		background: #fff;
		.hd-title{
			padding: 20rpx 0;
			font-size: 30rpx;
			font-weight: bold;
		}
		.item{
			display: flex;
			padding: 25rpx 0;
			border-bottom: 1rpx solid #eee;
			font-size: 30rpx;
			.label{
				width: 180rpx;
			}
			.phone{
				flex-grow: 2;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.link{
					display: flex;
					justify-content: space-between;
					align-items: center;
				}
			}
		}
	}  
	.fixed-btn{
		position: fixed;	
			z-index: 10000;
		bottom:120rpx;
		width: 100rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #d72b29;
		border-radius: 50%;
		color: #fff;
		font-size: 28rpx;
		text{			
			width: 70rpx; 
			text-align: center;
		}
	}
	.jq{
		left:30rpx;
	}
	.bz{ 
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		background: none;
		right:20rpx;
		top: 60rpx;
		font-size: 26rpx;
		color: #333;
		image{
			width: 36rpx;
		}
		text{
			width: 100rpx; 
		}
	}
</style>
